﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="sooritakanne_kandesisuv2", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(SooritakanneKandesisuv2))]
    public class SooritakanneKandesisuv2Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ISooritakanneKandesisuv2 clazz;
        
        public SooritakanneKandesisuv2Serializer(ISooritakanneKandesisuv2 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Registrikood!=null) {
                Writer.WriteStartElement("registrikood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Registrikood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgneArinimi!=null) {
                Writer.WriteStartElement("algne_arinimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AlgneArinimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.UusArinimi!=null) {
                Writer.WriteStartElement("uus_arinimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.UusArinimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OiguslikVorm!=null) {
                Writer.WriteStartElement("oiguslik_vorm");
                Writer.WriteTypeAttribute("http://producers.arireg.xtee.riik.ee/producer/arireg", "x_oigvorm");
                Writer.WriteString(clazz.OiguslikVorm.ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OiguslikuVormiAlaliik!=null) {
                Writer.WriteStartElement("oigusliku_vormi_alaliik");
                Writer.WriteTypeAttribute("http://producers.arireg.xtee.riik.ee/producer/arireg", "x_oigusliku_vormi_alaliik");
                Writer.WriteString(clazz.OiguslikuVormiAlaliik.ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Asukoht!=null) {
                Writer.WriteStartElement("asukoht");
                global::Xtee.Core.SerializationMetadata metaAsukoht = this.GetMetaData(clazz.Asukoht);
                Writer.WriteTypeAttribute(metaAsukoht.TypeQualifiedName.Namespace, metaAsukoht.TypeQualifiedName.Name);
                metaAsukoht.NewSerializer(clazz.Asukoht).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.Pohitegevusala!=null) {
                Writer.WriteStartElement("pohitegevusala");
                global::Xtee.Core.SerializationMetadata metaPohitegevusala = this.GetMetaData(clazz.Pohitegevusala);
                Writer.WriteTypeAttribute(metaPohitegevusala.TypeQualifiedName.Namespace, metaPohitegevusala.TypeQualifiedName.Name);
                metaPohitegevusala.NewSerializer(clazz.Pohitegevusala).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.Lisategevusala!=null) {
                Writer.WriteStartElement("lisategevusala");
                global::Xtee.Core.SerializationMetadata metaLisategevusala = this.GetMetaData(clazz.Lisategevusala);
                Writer.WriteTypeAttribute(metaLisategevusala.TypeQualifiedName.Namespace, metaLisategevusala.TypeQualifiedName.Name);
                metaLisategevusala.NewSerializer(clazz.Lisategevusala).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.Eesmargid!=null) {
                Writer.WriteStartElement("eesmargid");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("string", "http://www.w3.org/2001/XMLSchema", clazz.Eesmargid.Count);
                if (((clazz.Eesmargid == null) 
                            || (clazz.Eesmargid.Count < 1m))) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                for (int x = 0; ((clazz.Eesmargid != null) 
                            && (x < clazz.Eesmargid.Count)); x = (x + 1)) {
                    Writer.WriteStartElement("item");
                    if (clazz.Eesmargid[x]!=null) {
                        Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                        Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Eesmargid[x]))).ToString());
                    }
                    else {
                        Writer.WriteAttributeString("xsi", "nil", null, "1");
                    }
                    Writer.WriteEndElement();
                }
                Writer.WriteEndElement();
            }
            if (clazz.Majandusaasta!=null) {
                Writer.WriteStartElement("majandusaasta");
                global::Xtee.Core.SerializationMetadata metaMajandusaasta = this.GetMetaData(clazz.Majandusaasta);
                Writer.WriteTypeAttribute(metaMajandusaasta.TypeQualifiedName.Namespace, metaMajandusaasta.TypeQualifiedName.Name);
                metaMajandusaasta.NewSerializer(clazz.Majandusaasta).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.Kapital!=null) {
                Writer.WriteStartElement("kapital");
                global::Xtee.Core.SerializationMetadata metaKapital = this.GetMetaData(clazz.Kapital);
                Writer.WriteTypeAttribute(metaKapital.TypeQualifiedName.Namespace, metaKapital.TypeQualifiedName.Name);
                metaKapital.NewSerializer(clazz.Kapital).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.KapitaliJagunemised!=null) {
                Writer.WriteStartElement("kapitali_jagunemised");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("kapitaliJagunemineType", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.KapitaliJagunemised.Count);
                if (((clazz.KapitaliJagunemised == null) 
                            || (clazz.KapitaliJagunemised.Count < 1m))) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                for (int x = 0; ((clazz.KapitaliJagunemised != null) 
                            && (x < clazz.KapitaliJagunemised.Count)); x = (x + 1)) {
                    Writer.WriteStartElement("item");
                    if (clazz.KapitaliJagunemised[x]!=null) {
                        global::Xtee.Core.SerializationMetadata metaKapitaliJagunemised = this.GetMetaData(clazz.KapitaliJagunemised[x]);
                        Writer.WriteTypeAttribute(metaKapitaliJagunemised.TypeQualifiedName.Namespace, metaKapitaliJagunemised.TypeQualifiedName.Name);
                        metaKapitaliJagunemised.NewSerializer(clazz.KapitaliJagunemised[x]).WriteXml(Writer);
                    }
                    else {
                        Writer.WriteAttributeString("xsi", "nil", null, "1");
                    }
                    Writer.WriteEndElement();
                }
                Writer.WriteEndElement();
            }
            if (clazz.Esindusoigused!=null) {
                Writer.WriteStartElement("esindusoigused");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("esindusoigusType", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Esindusoigused.Count);
                if (((clazz.Esindusoigused == null) 
                            || (clazz.Esindusoigused.Count < 1m))) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                for (int x = 0; ((clazz.Esindusoigused != null) 
                            && (x < clazz.Esindusoigused.Count)); x = (x + 1)) {
                    Writer.WriteStartElement("item");
                    if (clazz.Esindusoigused[x]!=null) {
                        global::Xtee.Core.SerializationMetadata metaEsindusoigused = this.GetMetaData(clazz.Esindusoigused[x]);
                        Writer.WriteTypeAttribute(metaEsindusoigused.TypeQualifiedName.Namespace, metaEsindusoigused.TypeQualifiedName.Name);
                        metaEsindusoigused.NewSerializer(clazz.Esindusoigused[x]).WriteXml(Writer);
                    }
                    else {
                        Writer.WriteAttributeString("xsi", "nil", null, "1");
                    }
                    Writer.WriteEndElement();
                }
                Writer.WriteEndElement();
            }
            if (clazz.Pohikiri!=null) {
                Writer.WriteStartElement("pohikiri");
                global::Xtee.Core.SerializationMetadata metaPohikiri = this.GetMetaData(clazz.Pohikiri);
                Writer.WriteTypeAttribute(metaPohikiri.TypeQualifiedName.Namespace, metaPohikiri.TypeQualifiedName.Name);
                metaPohikiri.NewSerializer(clazz.Pohikiri).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.Sidevahendid!=null) {
                Writer.WriteStartElement("sidevahendid");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("sidevahendType", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Sidevahendid.Count);
                if (((clazz.Sidevahendid == null) 
                            || (clazz.Sidevahendid.Count < 1m))) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                for (int x = 0; ((clazz.Sidevahendid != null) 
                            && (x < clazz.Sidevahendid.Count)); x = (x + 1)) {
                    Writer.WriteStartElement("item");
                    if (clazz.Sidevahendid[x]!=null) {
                        global::Xtee.Core.SerializationMetadata metaSidevahendid = this.GetMetaData(clazz.Sidevahendid[x]);
                        Writer.WriteTypeAttribute(metaSidevahendid.TypeQualifiedName.Namespace, metaSidevahendid.TypeQualifiedName.Name);
                        metaSidevahendid.NewSerializer(clazz.Sidevahendid[x]).WriteXml(Writer);
                    }
                    else {
                        Writer.WriteAttributeString("xsi", "nil", null, "1");
                    }
                    Writer.WriteEndElement();
                }
                Writer.WriteEndElement();
            }
            if (clazz.SeotudIsikud!=null) {
                Writer.WriteStartElement("seotud_isikud");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("seotud_isikType", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.SeotudIsikud.Count);
                if (((clazz.SeotudIsikud == null) 
                            || (clazz.SeotudIsikud.Count < 1m))) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                for (int x = 0; ((clazz.SeotudIsikud != null) 
                            && (x < clazz.SeotudIsikud.Count)); x = (x + 1)) {
                    Writer.WriteStartElement("item");
                    if (clazz.SeotudIsikud[x]!=null) {
                        global::Xtee.Core.SerializationMetadata metaSeotudIsikud = this.GetMetaData(clazz.SeotudIsikud[x]);
                        Writer.WriteTypeAttribute(metaSeotudIsikud.TypeQualifiedName.Namespace, metaSeotudIsikud.TypeQualifiedName.Name);
                        metaSeotudIsikud.NewSerializer(clazz.SeotudIsikud[x]).WriteXml(Writer);
                    }
                    else {
                        Writer.WriteAttributeString("xsi", "nil", null, "1");
                    }
                    Writer.WriteEndElement();
                }
                Writer.WriteEndElement();
            }
            if (clazz.Markused!=null) {
                Writer.WriteStartElement("markused");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("string", "http://www.w3.org/2001/XMLSchema", clazz.Markused.Count);
                if (((clazz.Markused == null) 
                            || (clazz.Markused.Count < 1m))) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                for (int x = 0; ((clazz.Markused != null) 
                            && (x < clazz.Markused.Count)); x = (x + 1)) {
                    Writer.WriteStartElement("item");
                    if (clazz.Markused[x]!=null) {
                        Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                        Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Markused[x]))).ToString());
                    }
                    else {
                        Writer.WriteAttributeString("xsi", "nil", null, "1");
                    }
                    Writer.WriteEndElement();
                }
                Writer.WriteEndElement();
            }
            if (clazz.TegutsemiseAlgus!=null) {
                Writer.WriteStartElement("tegutsemise_algus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.TegutsemiseAlgus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TegutsemiseTahtaeg!=null) {
                Writer.WriteStartElement("tegutsemise_tahtaeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.TegutsemiseTahtaeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AsutamiseAeg!=null) {
                Writer.WriteStartElement("asutamise_aeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsutamiseAeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ViideEelkaijale!=null) {
                Writer.WriteStartElement("viide_eelkaijale");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.ViideEelkaijale))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kinnisasjad!=null) {
                Writer.WriteStartElement("kinnisasjad");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("kinnisasiType", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.Kinnisasjad.Count);
                if (((clazz.Kinnisasjad == null) 
                            || (clazz.Kinnisasjad.Count < 1m))) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                for (int x = 0; ((clazz.Kinnisasjad != null) 
                            && (x < clazz.Kinnisasjad.Count)); x = (x + 1)) {
                    Writer.WriteStartElement("item");
                    if (clazz.Kinnisasjad[x]!=null) {
                        global::Xtee.Core.SerializationMetadata metaKinnisasjad = this.GetMetaData(clazz.Kinnisasjad[x]);
                        Writer.WriteTypeAttribute(metaKinnisasjad.TypeQualifiedName.Namespace, metaKinnisasjad.TypeQualifiedName.Name);
                        metaKinnisasjad.NewSerializer(clazz.Kinnisasjad[x]).WriteXml(Writer);
                    }
                    else {
                        Writer.WriteAttributeString("xsi", "nil", null, "1");
                    }
                    Writer.WriteEndElement();
                }
                Writer.WriteEndElement();
            }
            if (clazz.ValismaaEmaettevote!=null) {
                Writer.WriteStartElement("valismaa_emaettevote");
                global::Xtee.Core.SerializationMetadata metaValismaaEmaettevote = this.GetMetaData(clazz.ValismaaEmaettevote);
                Writer.WriteTypeAttribute(metaValismaaEmaettevote.TypeQualifiedName.Namespace, metaValismaaEmaettevote.TypeQualifiedName.Name);
                metaValismaaEmaettevote.NewSerializer(clazz.ValismaaEmaettevote).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.FieSeisundid!=null) {
                Writer.WriteStartElement("fie_seisundid");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("sooritakanne_fieseisund", "http://producers.arireg.xtee.riik.ee/producer/arireg", clazz.FieSeisundid.Count);
                if (((clazz.FieSeisundid == null) 
                            || (clazz.FieSeisundid.Count < 1m))) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                for (int x = 0; ((clazz.FieSeisundid != null) 
                            && (x < clazz.FieSeisundid.Count)); x = (x + 1)) {
                    Writer.WriteStartElement("item");
                    if (clazz.FieSeisundid[x]!=null) {
                        global::Xtee.Core.SerializationMetadata metaFieSeisundid = this.GetMetaData(clazz.FieSeisundid[x]);
                        Writer.WriteTypeAttribute(metaFieSeisundid.TypeQualifiedName.Namespace, metaFieSeisundid.TypeQualifiedName.Name);
                        metaFieSeisundid.NewSerializer(clazz.FieSeisundid[x]).WriteXml(Writer);
                    }
                    else {
                        Writer.WriteAttributeString("xsi", "nil", null, "1");
                    }
                    Writer.WriteEndElement();
                }
                Writer.WriteEndElement();
            }
            if (clazz.MaksRegKpv!=null) {
                Writer.WriteStartElement("maks_reg_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.MaksRegKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "registrikood")) {
                goto registrikood;
            }
            else {
                if ((Reader.LocalName == "algne_arinimi")) {
                    goto algne_arinimi;
                }
                else {
                    if ((Reader.LocalName == "uus_arinimi")) {
                        goto uus_arinimi;
                    }
                    else {
                        if ((Reader.LocalName == "oiguslik_vorm")) {
                            goto oiguslik_vorm;
                        }
                        else {
                            if ((Reader.LocalName == "oigusliku_vormi_alaliik")) {
                                goto oigusliku_vormi_alaliik;
                            }
                            else {
                                if ((Reader.LocalName == "asukoht")) {
                                    goto asukoht;
                                }
                                else {
                                    if ((Reader.LocalName == "pohitegevusala")) {
                                        goto pohitegevusala;
                                    }
                                    else {
                                        if ((Reader.LocalName == "lisategevusala")) {
                                            goto lisategevusala;
                                        }
                                        else {
                                            if ((Reader.LocalName == "eesmargid")) {
                                                goto eesmargid;
                                            }
                                            else {
                                                if ((Reader.LocalName == "majandusaasta")) {
                                                    goto majandusaasta;
                                                }
                                                else {
                                                    if ((Reader.LocalName == "kapital")) {
                                                        goto kapital;
                                                    }
                                                    else {
                                                        if ((Reader.LocalName == "kapitali_jagunemised")) {
                                                            goto kapitali_jagunemised;
                                                        }
                                                        else {
                                                            if ((Reader.LocalName == "esindusoigused")) {
                                                                goto esindusoigused;
                                                            }
                                                            else {
                                                                if ((Reader.LocalName == "pohikiri")) {
                                                                    goto pohikiri;
                                                                }
                                                                else {
                                                                    if ((Reader.LocalName == "sidevahendid")) {
                                                                        goto sidevahendid;
                                                                    }
                                                                    else {
                                                                        if ((Reader.LocalName == "seotud_isikud")) {
                                                                            goto seotud_isikud;
                                                                        }
                                                                        else {
                                                                            if ((Reader.LocalName == "markused")) {
                                                                                goto markused;
                                                                            }
                                                                            else {
                                                                                if ((Reader.LocalName == "tegutsemise_algus")) {
                                                                                    goto tegutsemise_algus;
                                                                                }
                                                                                else {
                                                                                    if ((Reader.LocalName == "tegutsemise_tahtaeg")) {
                                                                                        goto tegutsemise_tahtaeg;
                                                                                    }
                                                                                    else {
                                                                                        if ((Reader.LocalName == "asutamise_aeg")) {
                                                                                            goto asutamise_aeg;
                                                                                        }
                                                                                        else {
                                                                                            if ((Reader.LocalName == "viide_eelkaijale")) {
                                                                                                goto viide_eelkaijale;
                                                                                            }
                                                                                            else {
                                                                                                if ((Reader.LocalName == "kinnisasjad")) {
                                                                                                    goto kinnisasjad;
                                                                                                }
                                                                                                else {
                                                                                                    if ((Reader.LocalName == "valismaa_emaettevote")) {
                                                                                                        goto valismaa_emaettevote;
                                                                                                    }
                                                                                                    else {
                                                                                                        if ((Reader.LocalName == "fie_seisundid")) {
                                                                                                            goto fie_seisundid;
                                                                                                        }
                                                                                                        else {
                                                                                                            if ((Reader.LocalName == "maks_reg_kpv")) {
                                                                                                                goto maks_reg_kpv;
                                                                                                            }
                                                                                                            else {
                                                                                                                return;
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        registrikood:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>registrikood");
            }
            clazz.Registrikood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("registrikood")).Value;
            goto START;
        algne_arinimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>algne_arinimi");
            }
            clazz.AlgneArinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("algne_arinimi")).Value;
            goto START;
        uus_arinimi:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>uus_arinimi");
            }
            clazz.UusArinimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("uus_arinimi")).Value;
            goto START;
        oiguslik_vorm:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>oiguslik_vorm");
            }
            clazz.OiguslikVorm = new global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.XOigvorm(Reader.ReadElementString("oiguslik_vorm"));
            goto START;
        oigusliku_vormi_alaliik:
            if ((Reader.IsElementNil() == false)) {
                clazz.OiguslikuVormiAlaliik = new global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.XOiguslikuVormiAlaliik(Reader.ReadElementString("oigusliku_vormi_alaliik"));
            }
            else {
                Reader.Skip();
            }
            goto START;
        asukoht:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>asukoht");
            }
            global::Xtee.Core.SerializationMetadata metaAsukoht = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IAadressType>(Reader, "aadressType", "http://producers.arireg.xtee.riik.ee/producer/arireg");
            clazz.Asukoht = metaAsukoht.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IAadressType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("asukoht");
                metaAsukoht.NewSerializer(clazz.Asukoht).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        pohitegevusala:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>pohitegevusala");
            }
            global::Xtee.Core.SerializationMetadata metaPohitegevusala = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ITegevusalaType>(Reader, "tegevusalaType", "http://producers.arireg.xtee.riik.ee/producer/arireg");
            clazz.Pohitegevusala = metaPohitegevusala.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ITegevusalaType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("pohitegevusala");
                metaPohitegevusala.NewSerializer(clazz.Pohitegevusala).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        lisategevusala:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>lisategevusala");
            }
            global::Xtee.Core.SerializationMetadata metaLisategevusala = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ITegevusalaType>(Reader, "tegevusalaType", "http://producers.arireg.xtee.riik.ee/producer/arireg");
            clazz.Lisategevusala = metaLisategevusala.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ITegevusalaType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("lisategevusala");
                metaLisategevusala.NewSerializer(clazz.Lisategevusala).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        eesmargid:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>eesmargid");
            }
            clazz.Eesmargid = new System.Collections.Generic.List<System.String>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("eesmargid");
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "item")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        clazz.Eesmargid.Add(new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("item")).Value);
                    }
                    else {
                        clazz.Eesmargid.Add(null);
                        Reader.Skip();
                    }
                }
                if ((clazz.Eesmargid.Count < 1m)) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        majandusaasta:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>majandusaasta");
            }
            global::Xtee.Core.SerializationMetadata metaMajandusaasta = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneMajaasta>(Reader, "sooritakanne_majaasta", "http://producers.arireg.xtee.riik.ee/producer/arireg");
            clazz.Majandusaasta = metaMajandusaasta.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneMajaasta>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("majandusaasta");
                metaMajandusaasta.NewSerializer(clazz.Majandusaasta).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        kapital:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>kapital");
            }
            global::Xtee.Core.SerializationMetadata metaKapital = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneKapital>(Reader, "sooritakanne_kapital", "http://producers.arireg.xtee.riik.ee/producer/arireg");
            clazz.Kapital = metaKapital.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneKapital>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("kapital");
                metaKapital.NewSerializer(clazz.Kapital).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        kapitali_jagunemised:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>kapitali_jagunemised");
            }
            clazz.KapitaliJagunemised = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKapitaliJagunemineType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("kapitali_jagunemised");
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "item")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaKapitaliJagunemised = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKapitaliJagunemineType>(Reader, "kapitaliJagunemineType", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKapitaliJagunemineType item = metaKapitaliJagunemised.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKapitaliJagunemineType>();
                        clazz.KapitaliJagunemised.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaKapitaliJagunemised.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.KapitaliJagunemised.Add(null);
                        Reader.Skip();
                    }
                }
                if ((clazz.KapitaliJagunemised.Count < 1m)) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        esindusoigused:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>esindusoigused");
            }
            clazz.Esindusoigused = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEsindusoigusType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("esindusoigused");
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "item")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaEsindusoigused = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEsindusoigusType>(Reader, "esindusoigusType", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEsindusoigusType item = metaEsindusoigused.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IEsindusoigusType>();
                        clazz.Esindusoigused.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaEsindusoigused.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.Esindusoigused.Add(null);
                        Reader.Skip();
                    }
                }
                if ((clazz.Esindusoigused.Count < 1m)) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        pohikiri:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>pohikiri");
            }
            global::Xtee.Core.SerializationMetadata metaPohikiri = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakannePohikiri>(Reader, "sooritakanne_pohikiri", "http://producers.arireg.xtee.riik.ee/producer/arireg");
            clazz.Pohikiri = metaPohikiri.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakannePohikiri>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("pohikiri");
                metaPohikiri.NewSerializer(clazz.Pohikiri).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        sidevahendid:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>sidevahendid");
            }
            clazz.Sidevahendid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISidevahendType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("sidevahendid");
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "item")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaSidevahendid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISidevahendType>(Reader, "sidevahendType", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISidevahendType item = metaSidevahendid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISidevahendType>();
                        clazz.Sidevahendid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaSidevahendid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.Sidevahendid.Add(null);
                        Reader.Skip();
                    }
                }
                if ((clazz.Sidevahendid.Count < 1m)) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        seotud_isikud:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>seotud_isikud");
            }
            clazz.SeotudIsikud = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISeotudIsikType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("seotud_isikud");
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "item")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaSeotudIsikud = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISeotudIsikType>(Reader, "seotud_isikType", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISeotudIsikType item = metaSeotudIsikud.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISeotudIsikType>();
                        clazz.SeotudIsikud.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaSeotudIsikud.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.SeotudIsikud.Add(null);
                        Reader.Skip();
                    }
                }
                if ((clazz.SeotudIsikud.Count < 1m)) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        markused:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>markused");
            }
            clazz.Markused = new System.Collections.Generic.List<System.String>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("markused");
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "item")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        clazz.Markused.Add(new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("item")).Value);
                    }
                    else {
                        clazz.Markused.Add(null);
                        Reader.Skip();
                    }
                }
                if ((clazz.Markused.Count < 1m)) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        tegutsemise_algus:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>tegutsemise_algus");
            }
            clazz.TegutsemiseAlgus = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("tegutsemise_algus")).Value;
            goto START;
        tegutsemise_tahtaeg:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>tegutsemise_tahtaeg");
            }
            clazz.TegutsemiseTahtaeg = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("tegutsemise_tahtaeg")).Value;
            goto START;
        asutamise_aeg:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>asutamise_aeg");
            }
            clazz.AsutamiseAeg = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("asutamise_aeg")).Value;
            goto START;
        viide_eelkaijale:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>viide_eelkaijale");
            }
            clazz.ViideEelkaijale = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("viide_eelkaijale")).Value;
            goto START;
        kinnisasjad:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>kinnisasjad");
            }
            clazz.Kinnisasjad = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKinnisasiType>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("kinnisasjad");
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "item")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaKinnisasjad = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKinnisasiType>(Reader, "kinnisasiType", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKinnisasiType item = metaKinnisasjad.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.IKinnisasiType>();
                        clazz.Kinnisasjad.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaKinnisasjad.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.Kinnisasjad.Add(null);
                        Reader.Skip();
                    }
                }
                if ((clazz.Kinnisasjad.Count < 1m)) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        valismaa_emaettevote:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>valismaa_emaettevote");
            }
            global::Xtee.Core.SerializationMetadata metaValismaaEmaettevote = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneVmemaettevote>(Reader, "sooritakanne_vmemaettevote", "http://producers.arireg.xtee.riik.ee/producer/arireg");
            clazz.ValismaaEmaettevote = metaValismaaEmaettevote.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneVmemaettevote>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("valismaa_emaettevote");
                metaValismaaEmaettevote.NewSerializer(clazz.ValismaaEmaettevote).ReadXml(Reader);
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        fie_seisundid:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>fie_seisundid");
            }
            clazz.FieSeisundid = new System.Collections.Generic.List<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneFieseisund>();
            if ((Reader.IsEmptyElement == false)) {
                Reader.ReadStartElement("fie_seisundid");
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "item")); ) {
                    if ((Reader.IsElementNil() == false)) {
                        global::Xtee.Core.SerializationMetadata metaFieSeisundid = this.GetMetaData<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneFieseisund>(Reader, "sooritakanne_fieseisund", "http://producers.arireg.xtee.riik.ee/producer/arireg");
                        global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneFieseisund item = metaFieSeisundid.NewEntity<global::Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg.ISooritakanneFieseisund>();
                        clazz.FieSeisundid.Add(item);
                        if ((Reader.IsEmptyElement == false)) {
                            Reader.ReadStartElement("item");
                            metaFieSeisundid.NewSerializer(item).ReadXml(Reader);
                            Reader.ReadEndElement();
                        }
                        else {
                            Reader.Skip();
                        }
                    }
                    else {
                        clazz.FieSeisundid.Add(null);
                        Reader.Skip();
                    }
                }
                if ((clazz.FieSeisundid.Count < 1m)) {
                    throw new global::Xtee.Core.Exceptions.MinOccurrenceException(1m, "item");
                }
                Reader.ReadEndElement();
            }
            else {
                Reader.Skip();
            }
            goto START;
        maks_reg_kpv:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>sooritakanne_kandesisuv2>maks_reg_kpv");
            }
            clazz.MaksRegKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("maks_reg_kpv")).Value;
            goto START;
        }
    }
}
